package model;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Vector;

public class DFANode {
	int label; /* 状态结点标记名 */
	int acceptstatetag; /* 接受状态标记，0为非接受状态，1为接受状态 */
	Vector<DFAEdge> edges;// 存发出边
	Map<Character, Integer> hashedges;// 存边的快表

	public DFANode(final DFANode n)// 结点的拷贝构造函数,为了支持vector中相关的插入弹出等操作
	{
		label = n.label;
		acceptstatetag = n.acceptstatetag;
		edges = n.edges;
		hashedges = n.hashedges;
	}

	public DFANode(int lab) {
		label = lab;
		acceptstatetag = 0;

	}

	public int getLabel() {
		return label;
	}

	public void setLabel(int label) {
		this.label = label;
	}

	public int getAcceptstatetag() {
		return acceptstatetag;
	}

	public void setAcceptstatetag(int acceptstatetag) {
		this.acceptstatetag = acceptstatetag;
	}

	public Vector<DFAEdge> getEdges() {
		return edges;
	}

	public void setEdges(Vector<DFAEdge> edges) {
		this.edges = edges;
	}

	public Map<Character, Integer> getHashedges() {
		return hashedges;
	}

	public void setHashedges(Map<Character, Integer> hashedges) {
		this.hashedges = hashedges;
	}

	public DFANode() {
		label = 0;
		acceptstatetag = 0;
	}

	public int nextId(char ch) {

		Character str;
		// 获取map集合中的所有键的Set集合
		Set<Character> reKeySet = hashedges.keySet();
		// 有了Set集合就可以获取其迭代器，取值
		Iterator<Character> iter = reKeySet.iterator();
		while (iter.hasNext()) {
			str = iter.next();
			if (str == ch) {
				return hashedges.get(str);
			}
		}
		return -1;
	}

}
